home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / pooyan.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  4KB  |  152 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13.  
  14. static int flipscreen;
  15.  
  16.  
  17.  
  18. /***************************************************************************
  19.  
  20.   Convert the color PROMs into a more useable format.
  21.  
  22.   Pooyan has one 32x8 palette PROM and two 256x4 lookup table PROMs
  23.   (one for characters, one for sprites).
  24.   The palette PROM is connected to the RGB output this way:
  25.  
  26.   bit 7 -- 220 ohm resistor  -- BLUE
  27.         -- 470 ohm resistor  -- BLUE
  28.         -- 220 ohm resistor  -- GREEN
  29.         -- 470 ohm resistor  -- GREEN
  30.         -- 1  kohm resistor  -- GREEN
  31.         -- 220 ohm resistor  -- RED
  32.         -- 470 ohm resistor  -- RED
  33.   bit 0 -- 1  kohm resistor  -- RED
  34.  
  35. ***************************************************************************/
  36. void pooyan_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  37. {
  38.     int i;
  39.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  40.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
  41.  
  42.  
  43.     for (i = 0;i < Machine->drv->total_colors;i++)
  44.     {
  45.         int bit0,bit1,bit2;
  46.  
  47.  
  48.         /* red component */
  49.         bit0 = (*color_prom >> 0) & 0x01;
  50.         bit1 = (*color_prom >> 1) & 0x01;
  51.         bit2 = (*color_prom >> 2) & 0x01;
  52.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  53.         /* green component */
  54.         bit0 = (*color_prom >> 3) & 0x01;
  55.         bit1 = (*color_prom >> 4) & 0x01;
  56.         bit2 = (*color_prom >> 5) & 0x01;
  57.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  58.         /* blue component */
  59.         bit0 = 0;
  60.         bit1 = (*color_prom >> 6) & 0x01;
  61.         bit2 = (*color_prom >> 7) & 0x01;
  62.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  63.  
  64.         color_prom++;
  65.     }
  66.  
  67.     /* color_prom now points to the beginning of the char lookup table */
  68.  
  69.     /* sprites */
  70.     for (i = 0;i < TOTAL_COLORS(1);i++)
  71.         COLOR(1,i) = *(color_prom++) & 0x0f;
  72.  
  73.     /* characters */
  74.     for (i = 0;i < TOTAL_COLORS(0);i++)
  75.         COLOR(0,i) = (*(color_prom++) & 0x0f) + 0x10;
  76. }
  77.  
  78.  
  79.  
  80. WRITE_HANDLER( pooyan_flipscreen_w )
  81. {
  82.     if (flipscreen != (data & 1))
  83.     {
  84.         flipscreen = data & 1;
  85.         memset(dirtybuffer,1,videoram_size);
  86.     }
  87. }
  88.  
  89.  
  90.  
  91. /***************************************************************************
  92.  
  93.   Draw the game screen in the given osd_bitmap.
  94.   Do NOT call osd_update_display() from this function, it will be called by
  95.   the main emulation engine.
  96.  
  97. ***************************************************************************/
  98. void pooyan_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  99. {
  100.     int offs;
  101.  
  102.  
  103.     /* for every character in the Video RAM, check if it has been modified */
  104.     /* since last time and update it accordingly. */
  105.     for (offs = videoram_size - 1;offs >= 0;offs--)
  106.     {
  107.         if (dirtybuffer[offs])
  108.         {
  109.             int sx,sy,flipx,flipy;
  110.  
  111.  
  112.             dirtybuffer[offs] = 0;
  113.  
  114.             sx = offs % 32;
  115.             sy = offs / 32;
  116.             flipx = colorram[offs] & 0x40;
  117.             flipy = colorram[offs] & 0x80;
  118.             if (flipscreen)
  119.             {
  120.                 sx = 31 - sx;
  121.                 sy = 31 - sy;
  122.                 flipx = !flipx;
  123.                 flipy = !flipy;
  124.             }
  125.  
  126.             drawgfx(tmpbitmap,Machine->gfx[0],
  127.                     videoram[offs] + 8 * (colorram[offs] & 0x20),
  128.                     colorram[offs] & 0x0f,
  129.                     flipx,flipy,
  130.                     8*sx,8*sy,
  131.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  132.         }
  133.     }
  134.  
  135.  
  136.     /* copy the character mapped graphics */
  137.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  138.  
  139.  
  140.     /* Draw the sprites. */
  141.     for (offs = 0;offs < spriteram_size;offs += 2)
  142.     {
  143.         /* TRANSPARENCY_COLOR is needed for the scores */
  144.         drawgfx(bitmap,Machine->gfx[1],
  145.                 spriteram[offs + 1],
  146.                 spriteram_2[offs] & 0x0f,
  147.                 spriteram_2[offs] & 0x40,~spriteram_2[offs] & 0x80,
  148.                 240-spriteram[offs],spriteram_2[offs + 1],
  149.                 &Machine->drv->visible_area,TRANSPARENCY_COLOR,0);
  150.     }
  151. }
  152.